package com.xinsoft.controller.erp;

import com.xinsoft.common.Response;
import com.xinsoft.entity.dto.*;
import com.xinsoft.entity.vo.ErpOutSourcingVO;
import com.xinsoft.service.impl.SyncPullBillAdapter;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

/**
 * 业务单据同步
 */
@RestController
@RequestMapping("/erp/pullBill")
public class ErpPullBillController {

    @Resource(name = "syncPullBillAdapter")
    private SyncPullBillAdapter syncPullBillAdapter;


    /**
     * 生产计划分页
     */
    @GetMapping("/productionSync")
    public Response<?> productionSync() {
        return syncPullBillAdapter.productionSync();
    }

    /**
     * 生产计划--同步近两年数据
     */
    @GetMapping("/productionSyncTwoYears")
    public Response<?> productionSyncTwoYears() {
        return syncPullBillAdapter.productionSyncTwoYears();
    }

    /**
     * 生产投料单分页
     */
    @PostMapping("/feedingSync")
    public Response<?> feedingSync(@RequestBody MesFeedingPlanPageParam mesFeedingPlanPageParam) {
        return syncPullBillAdapter.feedingSync(mesFeedingPlanPageParam);
    }

    /**
     * 生产投料单详情
     */
    @PostMapping("/feedingDetailSync")
    public Response<?> feedingDetailSync(@RequestBody List<Integer> ids) {
        return syncPullBillAdapter.feedingDetailSync(ids);
    }

    /**
     * 领料出库单分页
     */
    @PostMapping("/feedingOutSync")
    public Response<?> feedingOutSync(@RequestBody ErpFeedingOutPageParam param) {
        return syncPullBillAdapter.feedingOutSync(param);
    }

    /**
     * 领料出库单分页详情
     */
    @PostMapping("/feedingOutDetailSync")
    public Response<?> feedingOutDetailSync(@RequestBody List<Integer> ids) {
        return syncPullBillAdapter.feedingOutDetailSync(ids);
    }

    /**
     * 委外合同分页
     */
    @PostMapping("/sourcing")
    public Response<?> sourcing(@RequestBody ErpSourcingPageParam param) {
        List<ErpOutSourcingVO> sourcing = syncPullBillAdapter.sourcing(param);
        return Response.succeed(sourcing);
    }

    /**
     * 委外合同详情
     */
    @PostMapping("/sourcingItem")
    public Response<?> sourcingItem(@RequestBody List<Integer> ids) {
        return syncPullBillAdapter.sourcingItem(ids);
    }

    /**
     * 委外合同详情
     */
    @PostMapping("/sourcingItemList")
    public Response<?> sourcingItem(@RequestBody ErpSourcingPageParam param) {
        return syncPullBillAdapter.sourcingItem(param);
    }

    /**
     * 委外投料分页
     */
    @PostMapping("/sourcingFeeding")
    public Response<?> sourcingFeeding(@RequestBody ErpSourcingFeedingPageParam param) {
        return syncPullBillAdapter.sourcingFeeding(param);
    }

    /**
     * 委外投料详情
     */
    @PostMapping("/sourcingFeedingDetail")
    public Response<?> sourcingFeedingDetail(@RequestBody List<Integer> ids) {
        return syncPullBillAdapter.sourcingFeedingDetail(ids);
    }

    /**
     * 采购订单分页
     */
    @PostMapping("/purchase")
    public Response<?> purchase(@RequestBody ErpPurchasePageParam param) {
        return syncPullBillAdapter.purchase(param);
    }

    /**
     * 采购订单详情
     */
    @PostMapping("/purchaseDetail")
    public Response<?> purchaseDetail(@RequestBody List<Integer> ids) {
        return syncPullBillAdapter.purchaseDetail(ids);
    }

    /**
     * 采购收料通知分页
     */
    @PostMapping("/purchaseNoticeSync")
    public Response<?> purchaseNoticeSync(@RequestBody ErpPurchaseNoticePageParam scmPurchasePageParam) {
        return syncPullBillAdapter.purchaseNoticeSync(scmPurchasePageParam);
    }

    /**
     * 采购收料通知详情
     */
    @PostMapping("/purchaseNoticeDetailSync")
    public Response<?> purchaseNoticeDetailSync(@RequestBody List<Integer> ids) {
        return syncPullBillAdapter.purchaseNoticeDetailSync(ids);
    }

    /**
     * 采购收料通知详情
     */
    @PostMapping("/purchaseNoticeDetailList")
    public Response<?> purchaseNoticeDetailList(@RequestBody ErpPurchaseNoticePageParam param) {
        return syncPullBillAdapter.purchaseNoticeDetailSync(param);
    }

    /**
     * 发货通知分页
     */
    @PostMapping("/saleNoticeSync")
    public Response<?> saleNoticeSync(@RequestBody ScmSaleNoticeParam param) {
        return syncPullBillAdapter.saleNoticeSync(param);
    }

    /**
     * 发货通知详情
     */
    @PostMapping("/saleNoticeDetailSync")
    public Response<?> saleNoticeDetailSync(@RequestParam(value = "id", required = true) Integer id) {
        return syncPullBillAdapter.saleNoticeDetailSync(id);
    }

    /**
     * 销售订单分页
     */
    @PostMapping("/saleSync")
    public Response<?> saleSync(@RequestBody ErpSalePageParam param) {
        return syncPullBillAdapter.saleSync(param);
    }

    /**
     * 销售订单详情
     */
    @PostMapping("/saleDetailSync")
    public Response<?> saleDetailSync(@RequestBody List<Integer> ids) {
        return syncPullBillAdapter.saleDetailSync(ids);
    }

    /**
     * 盘点方案列表
     */
    @PostMapping("/stocktakingList")
    public Response<?> stocktakingList(@RequestBody ErpSalePageParam param) {
        return syncPullBillAdapter.stocktakingList(param);
    }

    /**
     * 盘点方案详情
     */
    @PostMapping("/stocktakingDetail")
    public Response<?> stocktakingDetail(@RequestParam(value = "id", required = true) Integer id) {
        return syncPullBillAdapter.stocktakingDetail(id);
    }

    /**
     * 实时库存分页
     */
    @PostMapping("/realtimeInventory")
    public Response<?> realtimeInventory(@RequestBody ErpRealTimePageParam param) {
        return Response.succeed(syncPullBillAdapter.realtimeInventory(param));
    }

}
